<template>
  <div class="outer">
    <h2>我是App组件</h2>
  </div>

</template>

<script setup lang="ts" name="App">

class Student {

  score: number
  private _age: number;
  private _name: string;

  constructor(name: string, score: number, age: number) {
    this._name = name;
    this.score = score;
    this._age = age;
  }

  get name() {
    return this._name
  }
  get age() {
    return this._age
  }
  set age(value: number) {
    if (value >= 0) {
      this._age = value
    }
  }

}

const student = new Student("zhangsan",22,99)
// setter方法
student.age = 80
// getter方法
console.log(student.name, student.age)

</script>

<style>
  .outer {
    background-color: #ddd;
    border-radius: 10px;
    padding: 5px;
    margin: 10px;
    box-shadow: 0 0 10px;
    width: 400px;
    height: 400px;
  }
  img {
    width: 180px;
  }
</style>